import 'package:flutter/services.dart';
import 'package:lishopflu/base/base_import.dart';
import 'package:lishopflu/base/view_import.dart';

import 'person_info_ctl.dart';


class PersonInfoPage extends BasePage<PersonInfoCtl>{

  @override
  void onCreate(BuildContext mContext) {
    setAppTitle('个人信息', actions: [
      IconButton(
        icon: Text('保存', style: TextStyle(color: Colors.white),),
        onPressed: controller.save,
      ),
    ]);
  }

  @override
  Widget pageBody(BuildContext context) {
    return SingleChildScrollView(
      child: Column(
        crossAxisAlignment: CrossAxisAlignment.center,
        children: [

          topHead(),

          Row(
            crossAxisAlignment: CrossAxisAlignment.center,
            children: [
              Expanded(
                flex: 1,
                child:Padding(
                  padding: EdgeInsets.only(left: 10, right: 10),
                  child: Obx(() => CommonWidget.labelEdit('用户ID', controller.idCtl.value, hintText: 'id',maxLines: 1, readOnly: true)),
                ),
              ),
              InkWell(
                child: Padding(padding: EdgeInsets.all(10), child: Icon(Icons.content_copy, color: AppColor.c979797,),),
                onTap: (){
                  if (StringUtil.isEmpty(controller.idCtl.value.text)){
                    return;
                  }
                  Clipboard.setData(ClipboardData(text: controller.idCtl.value.text));
                  toast('已复制');
                },
              ),
            ],
          ),
          CommonWidget.divide(),

          Row(
            crossAxisAlignment: CrossAxisAlignment.center,
            children: [
              Expanded(
                flex: 1,
                child:Padding(
                  padding: EdgeInsets.only(left: 10, right: 10),
                  child: Obx(() => CommonWidget.labelEdit('手机号码', controller.phoneCtl.value, hintText: '请输入手机号', inputType: TextInputType.phone, maxLines: 1, readOnly: true),),
                ),
              ),
              InkWell(
                child: Padding(padding: EdgeInsets.all(10), child: Text('修改'),),
                onTap: (){
                  controller.toChangePhone();
                },
              ),
            ],
          ),
          CommonWidget.divide(),

          Padding(
            padding: EdgeInsets.only(left: 10, right: 10),
            child: Obx(() => CommonWidget.labelEdit('姓名', controller.nameCtl.value, hintText: '请输入姓名', maxLines: 1),),
          ),
          CommonWidget.divide(),

          Padding(
            padding: EdgeInsets.only(left: 10, right: 10),
            child: Obx(() => CommonWidget.labelEdit('邮箱', controller.emailCtl.value, hintText: '请输入邮箱', maxLines: 1),),
          ),
          CommonWidget.divide(),
        ],
      ),
    );
  }

  Widget topHead(){
    return GestureDetector(
      behavior: HitTestBehavior.opaque,
      onTap: (){

      },
      child: Container(
        padding: EdgeInsets.only(top: 10, bottom: 10,),
        child: Column(
          children: [
            CircleAvatar(
              backgroundImage: AssetImage('images/banner4.jpg',),
              radius: 40,
            ),
            Padding(padding: EdgeInsets.all(8), child: Text('修改头像', style: TextStyle(color: AppColor.c979797, fontSize: 12),),),
          ],
        ),
      ),
    );
  }
}